<?php

namespace App\Repositories\Address;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\Address\DeliverRegionRepository;
use App\Models\Address\DeliverRegion;
use App\Validators\Address\DeliverRegionValidator;

/**
 * Class DeliverRegionRepositoryEloquent
 * @package namespace App\Repositories\Address;
 */
class DeliverRegionRepositoryEloquent extends BaseRepository implements DeliverRegionRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return DeliverRegion::class;
    }

    /**
     * 获取所有配送区域
     * @return mixed
     */
    public function getAllRegion(){
        return $this->findWhere(['status'=>1]);
    }

    /**
     * 根据配送区域，获取单个配送区域
     * @param int $id
     * @return mixed
     */
    public function getRegionByRegionId(int $id){
        return $this->findWhere(['id'=>$id]);
    }

    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }
}
